# coding:utf-8
import jieba.analyse
import pymysql


def get_conn():
    conn = pymysql.connect(
        host='localhost',
        port=3306,
        user='root',
        passwd='',
        db='lstm_car_comment'
    )
    return conn


def update(sql, args):
    conn = get_conn()
    cur = conn.cursor()
    cur.execute(sql, args)
    conn.commit()
    cur.close()
    conn.close()


def select(sql):
    conn = get_conn()
    cur = conn.cursor()
    cur.execute(sql)
    res = cur.fetchall()
    cur.close()
    conn.close()
    return res


sentence = ["人工智能（Artificial Intelligence），",
            "英文缩写为AI。它是研究、开发用于模拟、延伸和扩展人的智能的理论、方法、技术"]
keywords = " ".join(jieba.analyse.extract_tags(sentence=sentence, topK=1, withWeight=False, allowPOS=()))
print(keywords)
